<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018\9\25 0025
 * Time: 11:32
 */

namespace app\Lib\Model\SysConfig;


use app\Lib\Model\DbModel\AdminConfig;

class SysConfig implements \app\Lib\InterfaceIn\SysConfig\SysConfig
{
    /**
     * 获取配置值
     * @param $variable
     * @return string
     */
    static public function getValue($variable)
    {
        $cacheName ='SysConfigName_'.$variable;
        $result    =cache($cacheName);
        if(!$result){
            $model  = new AdminConfig();
            $map = [$model->_status=>1,$model->_variable=>$variable];
            $result = $model->where($map)->value($model->_keys_val);
            if($result){
                cache($cacheName,$result);
            }
        }
        return $result;
    }

    /**
     * 删除缓存
     * @param $variable
     * @return bool
     */
    static public function delValue($variable)
    {
        $cacheName ='SysConfigName_'.$variable;
        $result    =cache($cacheName);
        if($result){
            cache($cacheName,null);
        }
        return true;
    }


}